﻿@model IEnumerable<ESN.Models.CustomProfile>

@{
    ViewBag.Title = ViewBag.Group.GName +" "+ @ESN.Languages.LangString.Load("member_list", "Home");
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#lastMessage").hide();
        var stopLoad = false;
        function Load(skip) {
            var query = "/CoreService.svc/GetMemberList?id=@ViewBag.Group.GId&skip=" + skip;
            $.getJSON(query, function (result) {
                $.each(result.d, function (i, item) {
                    $("#theList").append('<tr><td><img height="30" src="' + item.Avatar + '" alt="avatar" /></td><td><a href="' + item.UserName + '/Home">' + item.DisplayName + '</a></td><td>' + item.Location + '</td><td>' + ((item.Gender) ? "Nữ" : "Nam") + '</td></tr>');
                });
            });
        }
        var currentRow = 20;
        $(window).scroll(function () {
            if (($(window).scrollTop() == $(document).height() - $(window).height()) && !stopLoad) {
                $("#lastMessage").show();
                Load(currentRow);
                currentRow = currentRow + 20;
                $("#lastMessage").hide();
            }
        });
    });
</script>
<h2>@ESN.Languages.LangString.Load("member_list", "Home")</h2>
<div>
    <div style="float: left; width : 520px; border-right : 1px dashed;">
        <table id="theList">
            <tr>
                <th></th>
                <th>@ESN.Languages.LangString.Load("displayname", "Profile")</th>
                <th>@ESN.Languages.LangString.Load("location", "Profile")</th>
                <th>@ESN.Languages.LangString.Load("gender", "Profile")</th>
            </tr>

        @foreach (var item in Model)
        {
            <tr>
                <td><img height="30" src="@item.Avatar" alt="avatar" /></td>
                <td><a href="/@item.UserName/Home">@item.DisplayName</a></td>
                <td>@item.Location</td>
                <td>
                    @if (item.Gender)
                    {
                        <span>@ESN.Languages.LangString.Load("man", "Profile")</span>
                    }
                    else
                    {
                        <span>@ESN.Languages.LangString.Load("woman", "Profile")</span>
                    }
                
                </td>
            </tr>
        }
        </table>
        <div id="lastMessage"><img width="300" height="43" src="/Content/images/loading.gif" alt="loading..." /></div>
    </div>
    <div style="float: right; width: 200px;padding-right:10px;">
        @Html.Partial("_GroupInfo", (ESN.Models.Group)ViewBag.Group)
    </div>
</div>